<div id="mws-container" class="clearfix">
    <div class="container">
        <div class="mws-panel grid_8">
            <div class="mws-panel-header"> <span class="mws-i-24 i-table-1">
                    OrderID: <?php echo $orderItems[0]['Order']['tracking_id']; ?></span> 
            </div>
            <div class="mws-panel-body">
                <div class="dataTables_wrapper">
                    <table class="mws-datatable-fn mws-table">
                        <thead>
                            <tr>
                                <th class="sorting_asc" rowspan="1" colspan="1" style="width: 141px;">Item </th>
                                <th class="sorting" rowspan="1" colspan="1" style="width: 119px;">Item ID (Item Qty)</th>
                                <th class=" sorting_1" rowspan="1" colspan="1" style="width: 139px;">Merchant Item Price</th>
                                <th class=" sorting_1" rowspan="1" colspan="1" style="width: 99px;">Merchant Token</th>
                                <th class=" sorting_1" rowspan="1" colspan="1" style="width: 99px;">Merchant Payout</th>
                                <th class=" sorting_1" rowspan="1" colspan="1" style="width: 99px;">Merchant Shipped</th>
                                <th class="sorting_asc" rowspan="1" colspan="1" style="width: 123px;">WonderE Commission (in percentage)</th>
                                <th class="sorting" rowspan="1" colspan="1" style="width: 127px;">WonderE Commission (in price) : </th>
                                <th class=" sorting_1" rowspan="1" colspan="1" style="width: 99px;">Action</th>
                            </tr>
                        </thead>
                        <tbody>

                            <?php
                            foreach ($orderItems as $orderItem) {
                                //pr($orderItem);
                                //exit;
                                ?>
                                <tr class="gradeA">
                                    <td class=" sorting_1">
                                        <?php
                                        echo $html->link($orderItem['OrderItem']['Product']['name'], array('controller' => 'products', 'action' => 'product', $orderItem['OrderItem']['Product']['slug'], 'admin' => false), array('target' => '_blank'));
                                        ?>
                                    </td>
                                    <td class=" sorting_1"> <?php echo $orderItem['OrderItem']['order_Item_Id'] . ' ( ' . $orderItem['OrderItem']['qty'] . ' )'; ?></td>
                                    <td class=" sorting_1">$<?php echo $orderItem['OrderItem']['price']; ?></td>
                                    <td class=" sorting_1"> <?php echo $orderItem['OrderItem']['Seller']['bs_dis_name'] . "
						  (" . $orderItem['OrderItem']['Seller']['merchant_token'] . ")"; ?></td>
                                    <td class=" sorting_1">
                                        <?php
                                        $seller_prices = $orderItems[0]['Order']['selllers_prices'];
                                        $seller_prices_exp = explode(',', $seller_prices);
                                        if (isset($seller_prices_exp) and ($seller_prices_exp)) {
                                            foreach ($seller_prices_exp as $seller_prices_e) {
                                                $seller_prices_e_exp = explode('-', $seller_prices_e);
                                                $seller_id = $seller_prices_e_exp[0];
                                                $seller_price = $seller_prices_e_exp[1];
                                                if (isset($seller_id) and ($seller_id == $orderItem['OrderItem']['seller_id'])) {
                                                    $merchant_get_price = $seller_price;
                                                }
                                            }
                                            echo "$" . $merchant_get_price;
                                        }
                                        //exit;
                                        ?>
                                    </td>
                                    <td class=" sorting_1">
                                        <?php
                                        if (isset($orderItem['OrderItem']['shipped']) and ($orderItem['OrderItem']['shipped'] == 1)) {
                                            echo "Shipped on :" . $orderItem['OrderItem']['shipping_start_date'] . '<br>';
                                            $next_7_date = _next_dates($orderItem['OrderItem']['shipping_start_date'], '7', 'd');
                                            echo "Expected on :" . $next_7_date;
                                        } else {
                                            echo "Unshipped";
                                        }
                                        ?>
                                    </td>
                                    <td class=" sorting_1"><?php echo $orderItem['OrderItem']['sell_percentage']; ?>%</td>
                                    <td class=" sorting_1">
                                        <?php
                                        echo "$" . ((($orderItem['OrderItem']['price'] * $orderItem['OrderItem']['qty']) * $orderItem['OrderItem']['sell_percentage']) / 100);
                                        ?>
                                    </td>  
                                    <td class=" sorting_1">
                                        <?php
                                        if (isset($orderItem['OrderItem']['shipped']) and ($orderItem['OrderItem']['shipped'] == 1)) {
                                            //echo "Shipped on ".$orderItem['OrderItem']['shipping_start_date'];
                                            $next_7_date = _next_dates($orderItem['OrderItem']['shipping_start_date'], '7', 'd');
                                            //echo $next_7_date;
                                            if (isset($next_7_date) and (date('Y-m-d') >= $next_7_date)) {
                                                if (isset($orderItem['OrderItem']['bank_code']) and ($orderItem['OrderItem']['bank_code'])
                                                        and !empty($orderItem['OrderItem']['bank_code'])) {
                                                    echo $html->link('Paid', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id'], $orderItem['OrderItem']['bank_code']), array('escape' => false, 'id' => 'alink'));
                                                } else {
                                                    echo $html->link('Pay Due', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id']), array('escape' => false, 'id' => 'alinkPaydue'));
                                                }
                                            } else {
                                                if (isset($orderItem['OrderItem']['bank_code']) and ($orderItem['OrderItem']['bank_code']) and !empty($orderItem['OrderItem']['bank_code'])) {
                                                    echo $html->link('Paid', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id'], $orderItem['OrderItem']['bank_code']), array('escape' => false, 'id' => 'alink'));
                                                } else {
                                                    echo $html->link('Pay', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id']), array('escape' => false, 'id' => 'alink'));
                                                }
                                            }
                                        } else {
                                            if (isset($orderItem['OrderItem']['bank_code']) and ($orderItem['OrderItem']['bank_code']) and !empty($orderItem['OrderItem']['bank_code'])) {
                                                echo $html->link('Paid', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id'], $orderItem['OrderItem']['bank_code']), array('escape' => false, 'id' => 'alink'));
                                            } else {
                                                echo $html->link('Pay', array('controller' => 'Setups', 'action' => 'admin_order_pay', $orderItem['OrderItem']['order_tracking_id'], $orderItem['OrderItem']['order_Item_Id']), array('escape' => false, 'id' => 'alink'));
                                            }
                                        }
                                        ?>
                                    </td>  

                                </tr>
                                        <?php
                                    }
                                    ?>
                            <tr class="">
                                <td class=" sorting_1" >&nbsp;</td>
                                <td class=" sorting_1" >&nbsp;</td>
                                <td class=" sorting_1">&nbsp;</td>
                                <td class=" sorting_1">&nbsp;</td>
                                <td class=" sorting_1">&nbsp;</td> 
                                <td class=" sorting_1">&nbsp;</td> 
                                <td class=" sorting_1">&nbsp;</td> 
                                <td class=" sorting_1">Total Commission Earned By WonderE </td> 
                                <td class=" sorting_1">$<?php echo $orderItems[0]['Order']['wondere_price']; ?></td>
                            </tr>
                        </tbody>
                    </table>
                    <!-- <div class="dataTables_info"></div>
                     <div class="dataTables_paginate paging_full_numbers">
                     </div>-->
                </div>
            </div>
        </div>
    </div>
</div>
